package com.iris.live.services.covervo;


import com.iris.live.services.common.DateFormatUtils;
import com.iris.live.services.common.DateUtils;
import com.iris.live.services.common.StringUtils;
import com.iris.live.services.data.models.CustomCarConfigureDetailModel;
import com.iris.live.services.vo.aftermarket.CustomCarConfigureDetailVo;
import com.iris.live.services.vo.customcarconfigure.CustomConfigureDetailPreviewVo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 封装加配详情
 */
public class CustomCarDetailCover {

    /**
     * 加配详情列表
     * @param list
     * @return
     * @throws Exception
     */
    public static List<CustomCarConfigureDetailVo> getCarDetailList(List<Map<String,String>> list){
        List<CustomCarConfigureDetailVo> volist =  new ArrayList<CustomCarConfigureDetailVo>();
        try{
            for (Map<String,String> model:list) {
                CustomCarConfigureDetailVo  vo = new CustomCarConfigureDetailVo(Integer.parseInt(String.valueOf(model.get("id"))),
                        null,
                        String.valueOf(model.get("productNum")),
                        Float.parseFloat( String.valueOf(model.get("boutiquePrice"))),
                        Integer.parseInt(String.valueOf(model.get("boutiqueNum"))),
                        String.valueOf(model.get("boutiqueName")),
                        Integer.parseInt(String.valueOf(model.get("storeId"))),
                        String.valueOf(model.get("customName")),
                        StringUtils.currencyFormat(Float.parseFloat(String.valueOf(model.get("discount")))),
                        Float.parseFloat(String.valueOf(model.get("receivable"))),
                        Float.parseFloat(String.valueOf(model.get("netReceipts"))),
                        Integer.parseInt(String.valueOf(model.get("status"))),
                        DateUtils.format(DateFormatUtils.getFormatDate(String.valueOf(model.get("createdTime")),"yyyy-MM-dd HH:mm:ss"),"yyyy-MM-dd HH:mm:ss"));
                volist.add(vo);
            }
        }catch (Exception e){
            return volist;
        }
        return volist;
    }


    /**
     * 加配详情列表
     * @param list
     * @return
     * @throws Exception
     */
    public static List<CustomConfigureDetailPreviewVo> getDetailPreviewList(List<CustomCarConfigureDetailModel> list){
        List<CustomConfigureDetailPreviewVo> voList =  new ArrayList<CustomConfigureDetailPreviewVo>();
        try{
            for (CustomCarConfigureDetailModel model: list) {
                CustomConfigureDetailPreviewVo vo = new CustomConfigureDetailPreviewVo(
                        model.getId(),
                        model.getBoutiqueName(),
                        "大昌行集团",
                        model.getBoutiqueNum(),
                        StringUtils.formatFloat(1,4,model.getBoutiquePrice()),
                        String.valueOf(StringUtils.formatFloat(1,4,model.getDiscount() * 100F)) + "%",
                        StringUtils.formatFloat(1,4,model.getNetReceipts() / model.getBoutiqueNum()),
                        StringUtils.formatFloat(1,4,model.getNetReceipts())
                );
                voList.add(vo);
            }
        }catch (Exception e){
            return voList;
        }
        return voList;
    }
}
